package com.example.barcodeapp.ui.wode.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.barcodeapp.R;
import com.example.barcodeapp.base.BaseAdapter;
import com.example.barcodeapp.common.Constants;
import com.example.barcodeapp.ui.wode.bean.DingDanBean;

import java.util.ArrayList;
import java.util.List;

public class HomeAdapter3 extends BaseAdapter {
    private ArrayList<DingDanBean.DataBean> list;
    public HomeAdapter3(Context context, List data) {
        super(context, data);
    }

    @Override
    protected int getLayout() {
        return R.layout.adapter_item_home;
    }

    @Override
    protected void bindData(BaseViewHolder vh, Object data) {
        DingDanBean.DataBean dataBean = (DingDanBean.DataBean) data;
        ImageView mIvImg = (ImageView) vh.getViewById(R.id.iv_img);
        TextView mTvTitleHome = (TextView) vh.getViewById(R.id.tv_title_home);
        TextView mTvInTroduce = (TextView) vh.getViewById(R.id.tv_introduce);
        TextView mTvIntroduction = (TextView) vh.getViewById(R.id.tv_introduction);
        TextView mTvPriceHome = (TextView) vh.getViewById(R.id.tv_price_home);
        TextView mTvCless = (TextView) vh.getViewById(R.id.tv_cless);
        ImageView mIvZhiFu = (ImageView) vh.getViewById(R.id.iv_zhifu);

        Glide.with(context).load(Constants.Base_TPUrl +dataBean.getFengmian()).into(mIvImg);
        mTvTitleHome.setText(dataBean.getName());
        mTvInTroduce.setText(dataBean.getDesc());
        mTvIntroduction.setText("讲师：" + dataBean.getJiangshi());
        mTvPriceHome.setText("¥" + dataBean.getPrice());
        mTvCless.setText(dataBean.getKeshi() + "课");
        int state = dataBean.getState();
        if (state == 1) {//未付款
            mIvZhiFu.setImageResource(R.drawable.weiwancheng);
        } else if (state == 2) {//已付款
            mIvZhiFu.setImageResource(R.drawable.wancheng);
        } else {//取消订单
            mIvZhiFu.setImageResource(R.drawable.wancheng);
        }
    }
}
